import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import {getUser} from "@/utils/getUserValue.js";

export const useCurrentMenuStore = defineStore('current-menu', () => {
  const currentTitle = ref("首页")
  const currentKey = ref("1")
  function changeCurrentTitle(val, key) {
    currentTitle.value = val
    currentKey.value = key
  }

  return { currentTitle,currentKey, changeCurrentTitle }
}, {
  persist: true,
})

// 筛选
export const useWorkSearchStore = defineStore("work-search", {
  state: () => ({
    count: [],
    address: [],
    flg: false,
  }),

  actions: {},
});

export const useUserStore = defineStore("user",()=> {
  const user = ref({})
 async function setUser() {
    user.value = await getUser()

    // setUser2(val)
  }

  return { user, setUser }
});
